<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

		<p:growl id="growl" showDetail="false" globalOnly="true" life="6000" autoUpdate="true" />
		<p:dialog header="#{msg.button_add_student}" widgetVar="newAlunoModal" modal="true"
			resizable="false" width="450" id="newAlunoModal">
			
			<h:form id="formNewAluno">
				<p:tabView>
					<p:tab title="#{msg.label_tab_title_person_data}">
						<h:panelGrid cellpadding="10">
							<p:row>
								<h:outputLabel value="#{msg.label_name}" styleClass="labelsPanelGrid" />
								<p:inputText maxlength="100" size="60" value="#{addStudentController.student.nome}" />
							</p:row>

							<p:row>
								<h:outputLabel value="#{msg.label_address}" styleClass="labelsPanelGrid" />
								<p:inputText maxlength="100" size="60" value="#{addStudentController.student.endereco}" />
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_number}" styleClass="labelsPanelGrid" /> 
									<p:inputText maxlength="5" size="5" value="#{addStudentController.student.numero}" />
								</label>

								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_neighbor}" styleClass="labelsPanelGrid" /> 
									<p:inputText maxlength="40" size="47" value="#{addStudentController.student.bairro}" />
								</label>
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel value="#{msg.label_state}" styleClass="labelsPanelGrid" />
									<p:selectOneMenu id="uf" value="#{addStudentController.student.cidade.uf.id}" >
										<f:selectItem itemLabel="..." itemValue="" />
										<p:ajax update="cidade" listener="#{addStudentController.ufChanged}" event="change" />
										<f:selectItems itemValue="#{model.id}" var="model" itemLabel="#{model.sigla}" value="#{addStudentController.listOfUf}"/>
									</p:selectOneMenu>
								</label>

								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel value="#{msg.label_city}" styleClass="labelsPanelGrid" /> 
									<p:selectOneMenu id="cidade" value="#{addStudentController.student.cidade.id}">
										<f:selectItem itemLabel="#{addStudentController.student.cidade.nome}" itemValue="#{addStudentController.student.cidade.id}" />
										<f:selectItems itemValue="#{model.id}" var="model" itemLabel="#{model.nome}" value="#{addStudentController.listOfCities}"/>	
									</p:selectOneMenu>
								</label>
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGridComboBox"> 
									<p:outputLabel for="nascimento" value="#{msg.label_birthday}" 
										styleClass="labelsPanelGrid" /> 
									<p:calendar id="nascimento"
										value="#{addStudentController.student.dataNascimento}" pattern="dd-MM-yyyy" mask="true" />
								</label>

								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel for="sexo" value="#{msg.label_gender}" styleClass="labelsPanelGrid" />
									<p:selectOneMenu id="sexo" value="#{addStudentController.student.sexo}">
										<f:selectItem itemLabel="#{msg.label_female}" itemValue="F" />
										<f:selectItem itemLabel="#{msg.label_male}" itemValue="M" />
									</p:selectOneMenu>
								</label>
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_cpf}" styleClass="labelsPanelGrid" /> 
									<p:inputMask maxlength="14" size="20" value="#{addStudentController.student.cpf}" mask="999.999.999-99" />
								</label>

								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_rg}" styleClass="labelsPanelGrid" /> 
									<p:inputText maxlength="14" size="25" value="#{addStudentController.student.rg}" />
								</label>
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_phone}" styleClass="labelsPanelGrid" /> 
									<p:inputMask maxlength="13" size="20" value="#{addStudentController.student.tel}" mask="(99)9999-9999" />
								</label>

								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_mobile}" styleClass="labelsPanelGrid" /> 
									<p:inputMask maxlength="13" size="25" value="#{addStudentController.student.cel}" mask="(99)9999-9999" />
								</label>
							</p:row>
						</h:panelGrid>
					</p:tab>

					<!-- Financeiro -->
					<p:tab title="#{msg.label_tab_title_finance}">
						<h:panelGrid cellpadding="10">
							<p:row>
								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_mensalidade}" styleClass="labelsPanelGrid" /> 
									<p:inputText id="mensalidadeValue" maxlength="6" size="15" value="#{addStudentController.student.valorMensalidade}" />
								</label>

								<label class="inlineFieldsPanelGrid"> 
									<h:outputLabel value="#{msg.label_personal}" styleClass="labelsPanelGrid" /> 
									<p:inputText id="personalValue" maxlength="6" size="15" value="#{addStudentController.student.valorPersonal}" />
								</label>
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel value="#{msg.label_responsible}" styleClass="labelsPanelGrid" /> 
									<p:selectOneMenu id="responsavelSelect" value="#{addStudentController.isResponsible}">
										<p:ajax listener="#{addStudentController.changeCheckIsResponsible}" update="responsavel" />
										<f:selectItem itemLabel="#{msg.label_select_responsible}" itemValue="" />
										<f:selectItem itemLabel="Próprio Aluno" itemValue="1" />
										<f:selectItem itemLabel="Terceiros" itemValue="0" />
									</p:selectOneMenu>
								</label>

								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel value="#{msg.label_responsible}" styleClass="labelsPanelGrid" /> 
									<p:selectOneMenu id="responsavel" value="#{addStudentController.student.responsavel.id}" disabled="#{addStudentController.enableResponsible}">
										<f:selectItems itemValue="#{model.id}" var="model" itemLabel="#{model.nome}" value="#{addStudentController.listOfResponsibles}" />
									</p:selectOneMenu>
								</label>
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel value="#{msg.label_day_of_payment}" styleClass="labelsPanelGrid" /> 
									<p:selectOneMenu id="dayOfPayment" value="#{addStudentController.student.vencimento.id}">
										<f:selectItems itemValue="#{model.id}" var="model" itemLabel="#{model.dia}" value="#{addStudentController.listOfDaysToPayment}" />
									</p:selectOneMenu>
								</label>

								<label class="inlineFieldsPanelGridComboBox"> 
									<h:outputLabel value="#{msg.label_payment_plain}" styleClass="labelsPanelGrid" /> 
									<p:selectOneMenu id="planoPagamento" value="#{addStudentController.student.planoPagamento.id}">
										<f:selectItems itemValue="#{model.id}" var="model" itemLabel="#{model.descricao}" value="#{addStudentController.listOfPlanPayment}" />
									</p:selectOneMenu>
								</label>
							</p:row>
						</h:panelGrid>
					</p:tab>

					<!-- Imagem -->
					<p:tab title="#{msg.label_tab_title_image}">
						<h:panelGrid cellpadding="10">
							
							<!-- Image -->
							<p:graphicImage alt="#{msg.label_image}" title="#{msg.label_profile_image}" url="#{addStudentController.student.imagem}" styleClass="profilePhotoOnSaveOrEdit" />
							
							<p:row>
								
								<p:fileUpload fileUploadListener="#{addStudentController.handleFileUpload}" 
											dragDropSupport="true" 
											fileLimit="1" 
											allowTypes="/(\.|\/)(gif|jpe?g|png)$/" styleClass="fileUpload" />
								
							</p:row>

							<p:row>
								<label class="inlineFieldsPanelGridComboBox"> 
									<p:commandButton
										value="#{msg.button_save}" process="@form"
										action="#{addStudentController.saveStudent}" update=":formShowAlunos"
										icon="ui-icon-disk" /> 
									<p:commandButton value="#{msg.button_close}" update=":formShowAlunos" 
											icon="ui-icon-circle-close" 
											onclick="PF('newAlunoModal').close();"
											action="#{studentManagerController.listStudents}" />
								</label>
							</p:row>
						</h:panelGrid>
					</p:tab>
				</p:tabView>
			</h:form>

		</p:dialog>
	
	<script type="text/javascript" src="${facesContext.externalContext.requestContextPath}/js/jquery/jquery.maskedinput.min.js"></script>
	
</ui:composition>
